package com.selfdriving.activity;

import java.util.ArrayList;
import java.util.List;
import net.tsz.afinal.annotation.view.ViewInject;
import com.selfdriving.R;
import com.selfdriving.adapter.SearchAdapter;
import com.selfdriving.bean.Feature;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;

public class SearchActivity extends BaseActivity {
	@ViewInject(id = R.id.feature_list)
	ListView feature_list;
	
	@ViewInject(id=R.id.spinner_1)
	Spinner spinner1;
	
	@ViewInject(id=R.id.spinner_2)
	Spinner spinner2;
	
	@ViewInject(id=R.id.spinner_3)
	Spinner spinner3;

	private List<Feature> features;

	private SearchAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View contentView = LayoutInflater.from(getParent()).inflate(R.layout.search, null);
		setContentView(contentView);
		ArrayAdapter<String> cityAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.city));
		ArrayAdapter<String> featureAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.feature_sort));
		ArrayAdapter<String> levelAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.feature_level));
		cityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
		featureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
		levelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
        spinner1.setAdapter(cityAdapter);
        spinner2.setAdapter(featureAdapter);
        spinner3.setAdapter(levelAdapter);
		
		features = new ArrayList<Feature>();
		
		for (int i = 0; i < 7; i++) {
			Feature feature = new Feature();
			features.add(feature);
		}
		adapter = new SearchAdapter(this, features);
		feature_list.setAdapter(adapter);
	}

}
